<template>
  <router-view/>
</template>

<script>
export default {
  data () {
    return {

    }
  },
  computed: {
    loginSessionCache () {
      return this.$store.getters['auth/getLoginSessionCache'];
    },
    loginSessionState (){
      return this.$store.getters['auth/getLoginSessionState'];
    }
  },
  methods: {
    initViewState (){
      if (this.loginSessionCache.online){
        this.$router.push('/');
      }else {
        this.$router.push('/auth');
      }
    },
    exit () {
      this.$store.commit('auth/exit');
      this.$Message.success('退出成功');
      window.location.reload();
    }
  },
  watch: {
    loginSessionState: function (newLoginSession) {
      if (newLoginSession.online){
        this.$Message.success('登录成功');
        this.$router.push('/');
      }
    }
  },
  created () {
    this.initViewState();
  }
}
</script>

<style>

</style>
